<!--
 * @Autor: Ruohong Yu
 * @Date: 2022-04-22 00:00:56
 * @LastEditors: Ruohong Yu
 * @LastEditTime: 2022-05-24 14:33:14
 * @Description: file content
 * @FilePath: \merword:\program\p\pythonProject\FTP_Project\templates\up.html
-->
<!DOCTYPE html>
<html>
<head>
  <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script>
    function beginload(){
      var uppath = document.getElementById('uploadin').value
      console.log(uppath)
      $.ajax({
        url: "http://127.0.0.1:8080/upload", //请求的url地址
        type: "post", //设置请求的http方式，method也可以
        dataType: "json",
        data: {
          path: uppath//向服务器端发送的数据
        },
        success: function (data) {
          //请求成功之后执行的回调函数
          alert("同步成功")
          window.location.href = './up'
        },
        error: function (error) {
          console.log(error);
        },
      });
    }

    function deletepath(time){
      console.log(time)
      $.ajax({
        url: "http://127.0.0.1:8080/delpath", //请求的url地址
        type: "post", //设置请求的http方式，method也可以
        dataType: "json",
        data: {
          time: time//向服务器端发送的数据
        },
        success: function (data) {
          //请求成功之后执行的回调函数
          alert("删除成功")
          window.location.href = './up'
        },
        error: function (error) {
          console.log(error);
        },
      });
    }
  </script>
</head>
<body>
  <div class="header">
    <div class="proname">COW FTP</div>
    <div class="proname"><a style="text-decoration: none;color: aliceblue;" href="./home">首页</a></div>
    <div class="proname"><a style="text-decoration: none;color: aliceblue;" href="./up">上传</a></div>
    <div class="proname"><a style="text-decoration: none;color: aliceblue;" href="./log">日志</a></div>
  </div>
  
  <div class="contain">
    <div class="upload">
      <input class="uploadin" id="uploadin" type="text" placeholder="请输入同步路径">
      <button class="uploadbt" onclick="beginload()">开始同步</button>
      <button class="uploadbt">暂停同步</button>
      <button class="uploadbt">取消同步</button>
    </div>
    <div class="pathlist">
      <div class="pathintro">
        <div class="pathintroname">名称</div>
        <div class="pathintroname">同步状态</div>
        <div class="pathintroname">同步时间</div>
        <div class="pathintroname">更新时间</div>
        <div class="pathintroname">操作</div>
      </div>
      {% if pathlist %}
        {% for path in pathlist %}
          <div class="path">
            <div class="pathintroname">{{path.name}}</div>
            <div class="pathintroname">{{path.state}}</div>
            <div class="pathintroname">{{path.uptime}}</div>
            <div class="pathintroname">{{path.retime}}</div>
            <div class="pathintroname pathintrobt" onclick='deletepath("{{path.uptime}}")'>删除</div>
          </div>
        {% endfor %}
      {% endif %}
        

    </div>
  </div>


</body>
<style>
  html,body{
    margin: 0;
    padding: 0;
    height: 100%;
    background: url("/static/assets/6.jpg") center no-repeat;
    background-size: 100% 100%;
    font-weight: 300;
  }
  a{
    outline: none;
    text-decoration: none;
    color: aliceblue;
  }
  .header{
    display: flex;
    width: 100%;
    height: 50px;
    line-height: 50px;
    background-color: #252a3be6;
    color: aliceblue;
  }
  .proname{
    width: 80px;
    color: aliceblue;
    margin-left: 30px;
  }
  .contain{
    margin: 0 10%;
    backdrop-filter: blur(3px);
  }
  .upload{
    width: 100%;
    height: 50px;
    line-height: 50px;
    text-align: center;
    background-color: #ffffff5b;
    color: aliceblue;
  }
  .uploadin{
    height: 30px;
    width: 20%;
    padding-left: 10px;

  }
  .pathlist{
    background-color: #ffffff2b;
    border-radius: 10px;
    color: aliceblue;
    border-radius: 0px 0px 7px 7px;
  }
  .uploadbt{
    height: 30px;
    cursor: pointer;
    width: 10%;
    background: #615754;
    border: 0;
    font-size: 15px;
    font-weight: 300;
    border-radius: 3px;
    color: aliceblue;
  }
  .uploadbt:hover{
    background: #fff;
    color: black;
    transition： 500ms;
  }
  .pathintro{
    display: flex;
    width: 100%;
    height: 40px;
    line-height: 40px;
  }
  .path{
    display: flex;
    width: 100%;
    height: 40px;
    line-height: 40px;
    color: aliceblue;
  }
  .pathintroname{
    flex: 1;
    width: 100%;
    text-align: center;
    overflow: hidden;
  }
  .pathintrobt{
    cursor: pointer;
    background-color: #1e1e20;
  }
  .pathintrobt:hover{
    background-color: white;
    color:#1e1e20;
    transition: 500ms;
  }
</style>
</html>